package lol.clann.minecraft.springboot.plugin.core.config.jackson;

import relocate.com.fasterxml.jackson.databind.introspect.AnnotatedMember;
import relocate.com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.stereotype.Component;

import java.lang.annotation.Annotation;

/**
 * @author pyz
 * @date 2018/10/13 上午11:38
 */
public class AnnotationFilter extends JacksonAnnotationIntrospector {

    /**
     * 展开注解
     *
     * @param ann
     * @return
     */
    @Override
    public boolean isAnnotationBundle(Annotation ann) {
        return true;
    }

    /**
     * 被JsonIgnore注解的注解与JsonIgnore等价
     *
     * @param m
     * @return
     */
    @Override
    public boolean hasIgnoreMarker(AnnotatedMember m) {
        return AnnotationUtils.findAnnotation(m.getAnnotated(), Component.class) != null;
    }
}
